﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
	xmlns:GraphSharp_Controls="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
	xmlns:Converters="clr-namespace:GraphSharp.Converters;assembly=GraphSharp.Controls"
	xmlns:WPFExtensions_AttachedBehaviours="clr-namespace:WPFExtensions.AttachedBehaviours;assembly=WPFExtensions"
>
	<Converters:EdgeRouteToPathConverter x:Key="routeToPathConverter" />
	<Controls:DependencyIconVertexConverter x:Key="IconConverter"/>
	
	<SolidColorBrush x:Key="HighlightedVertexBorderBrush" Color="Transparent" />
	<SolidColorBrush x:Key="HighlightedVertexBackgroundBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
	<SolidColorBrush x:Key="HighlightedVertexForegroundBrush" Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" />
	<SolidColorBrush x:Key="SemiHighlightedSourceVertexBorderBrush" Color="Transparent" />
	<SolidColorBrush x:Key="SemiHighlightedSourceVertexBackgroundBrush" Color="#FF1DBA00" />
	<SolidColorBrush x:Key="SemiHighlightedTargetVertexBorderBrush" Color="Transparent" />
	<SolidColorBrush x:Key="SemiHighlightedTargetVertexBackgroundBrush" Color="#FFD6A51C" />
	<SolidColorBrush x:Key="HighlightedEdgeBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
	<SolidColorBrush x:Key="SemiHighlightedInEdgeBrush" Color="#FF1DBA00" />
	<SolidColorBrush x:Key="SemiHighlightedOutEdgeBrush" Color="#FFD6A51C" />
	
	<!-- VERTEX CONTROL -->
	<Style TargetType="{x:Type GraphSharp_Controls:VertexControl}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type GraphSharp_Controls:VertexControl}">
					<Border Background="{TemplateBinding Background}"
					        BorderBrush="{TemplateBinding BorderBrush}"
					        BorderThickness="{TemplateBinding BorderThickness}"
					        CornerRadius="10,10,10,10"
					        Padding="{TemplateBinding Padding}">
						<StackPanel Orientation="Horizontal">
							<Image Margin="0, 1, 5, 0" Source="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GraphSharp_Controls:VertexControl}}, Path=Vertex, Converter={StaticResource IconConverter}}" />
							<ContentPresenter Content="{TemplateBinding Vertex}"/>
						</StackPanel>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger" Value="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"/>
		<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled" Value="True"/>
		<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.X), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
		<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.Y), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
		<Setter Property="Background" Value="#FFE3E3E3"/>
		<Setter Property="BorderThickness" Value="5,3,5,3"/>
		<Setter Property="Padding" Value="10,5,10,5"/>
		<Setter Property="BorderBrush" Value="#FF393939"/>
		<Setter Property="Controls:DependencyGraphLayout.IsSelectingEnabled" Value="True" />
		<Style.Triggers>
			<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="True">
				<Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
				<Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
			</Trigger>
			<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True">
				<Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
				<Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
			</Trigger>
			<Trigger Property="Controls:DependencyGraphLayout.IsSelected" Value="True">
				<Setter Property="Background">
					<Setter.Value>
						<SolidColorBrush Color="#FFFFA500" />
					</Setter.Value>
				</Setter>
			</Trigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Source"/>
				</MultiTrigger.Conditions>
				<Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedSourceVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource SemiHighlightedSourceVertexBackgroundBrush}"/>
			</MultiTrigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Target"/>
				</MultiTrigger.Conditions>
				<Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedTargetVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource SemiHighlightedTargetVertexBackgroundBrush}"/>
			</MultiTrigger>
		</Style.Triggers>
	</Style>
	
	<!-- EDGE CONTROL -->
	<Style TargetType="{x:Type GraphSharp_Controls:EdgeControl}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type GraphSharp_Controls:EdgeControl}">
					<Path Stroke="{TemplateBinding Foreground}"
					      MinWidth="1"
					      MinHeight="1"
					      ToolTip="{TemplateBinding ToolTip}"
					      x:Name="edgePath">
						<Path.Data>
							<PathGeometry>
								<PathGeometry.Figures>
									<MultiBinding Converter="{StaticResource routeToPathConverter}">
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Source.(GraphSharp_Controls:GraphCanvas.X)" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Source.(GraphSharp_Controls:GraphCanvas.Y)" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Source.ActualWidth" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Source.ActualHeight" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Target.(GraphSharp_Controls:GraphCanvas.X)" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Target.(GraphSharp_Controls:GraphCanvas.Y)" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Target.ActualWidth" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="Target.ActualHeight" />
										<Binding RelativeSource="{RelativeSource TemplatedParent}"
										         Path="RoutePoints" />
									</MultiBinding>
								</PathGeometry.Figures>
							</PathGeometry>
						</Path.Data>
					</Path>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger"
		        Value="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" />
		<Setter Property="MinWidth"
		        Value="1" />
		<Setter Property="MinHeight"
		        Value="1" />
		<Setter Property="Background"
		        Value="Red" />
		<Setter Property="Foreground"
		        Value="Silver" />
		<Setter Property="Opacity"
		        Value="0.5" />
		<Style.Triggers>
			<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted"
			         Value="True">
				<Setter Property="Foreground"
				        Value="{DynamicResource HighlightedEdgeBrush}" />
			</Trigger>
			<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
			         Value="True">
				<Setter Property="Foreground"
				        Value="{DynamicResource HighlightedEdgeBrush}" />
			</Trigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
					           Value="True" />
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
					           Value="InEdge" />
				</MultiTrigger.Conditions>
				<Setter Property="Foreground"
				        Value="{DynamicResource SemiHighlightedInEdgeBrush}" />
			</MultiTrigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
					           Value="True" />
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
					           Value="OutEdge" />
				</MultiTrigger.Conditions>
				<Setter Property="Foreground"
				        Value="{DynamicResource SemiHighlightedOutEdgeBrush}" />
			</MultiTrigger>
		</Style.Triggers>
	</Style>
</ResourceDictionary>